<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改未上传的维保联系单 ')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-sheet-edit" th:object="${proReportContactSheet}">
        <input id="mId" name="mId" th:field="*{mId}" type="hidden">
<!--        <div class="form-group" th:unless="${proReportContactSheet.mMreport} !=null">-->
<!--            <label class="col-sm-3 control-label">维保报告书 ：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input id="mMreport" name="file" th:field="*{mMreport}" class="form-control" type="file">-->
<!--            </div>-->
<!--        </div>-->
                    <div class="form-group" th:unless="${proReportContactSheet.mMcontactSheet} !=null">
                        <label class="col-sm-3 control-label">维保联系单：</label>
                        <div class="col-sm-8">
                            <input id="mMcontactSheet" name="file1" th:field="*{mMcontactSheet}" class="form-control" type="file">
                        </div>
                    </div>
<!--                    <div class="form-group" th:unless="${proReportContactSheet.mMforPayment} !=null">-->
<!--                        <label class="col-sm-3 control-label">维保费申请支付联系单：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="mMforPayment" name="file2" th:field="*{mMforPayment}" class="form-control" type="file">-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="form-group" th:unless="${proReportContactSheet.mCheckProblem} !=null">-->
<!--                        <label class="col-sm-3 control-label">排查问题联系单：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="mCheckProblem" name="file3" th:field="*{mCheckProblem}" class="form-control" type="file">-->
<!--                        </div>-->
<!--                    </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">创建时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input id="mTime" name="mTime" th:value="${#dates.format(proReportContactSheet.mTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                </div>
            </div>
        </div>
        <div class="form-group" hidden>
            <label class="col-sm-3 control-label">外键id：</label>
            <div class="col-sm-8">
                <input id="mtId" name="mtId" th:field="*{mtId}" class="form-control" type="hidden">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script type="text/javascript">
    var prefix = ctx + "ruoyi/sheet";
    $("#form-sheet-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            uploadFile();
            //$.operate.save(prefix + "/edit", $('#form-sheet-edit').serialize());
        }
    }

    function uploadFile() {
        var formData = new FormData();
        if($('#mMcontactSheet')[0].files[0]!=null)
        {
            formData.append('mId', $("#mId").val());
            //formData.append('file', $('#mMreport')[0].files[0]);
            formData.append('file1', $('#mMcontactSheet')[0].files[0]);
            //formData.append('file2', $('#mMforPayment')[0].files[0]);
            //formData.append('file3', $('#mCheckProblem')[0].files[0]);
            formData.append('mTime', $("#mTime").val());
            formData.append('mtId', $("#mtId").val());
            $.ajax({
                url: prefix + "/edits",
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function (result) {
                    $.operate.successCallback(result);
                }
            });
        }else{
            $.modal.alertWarning("请先选择文件路径");
            return false;
        }
    }

    $("input[name='mTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>